﻿using System;

namespace Program10
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(Factorial1(4));
            Console.WriteLine(Factorial2(4));
        }

        //前递归
        public static long Factorial1(int n)
        {
            if (n == 1 || n == 0)
                return 1;
            else
                return n * Factorial1(n - 1);
        }

        public static long Factorial2(int n)
        {
            var result = 1;
            for (var i = 1; i <= n; i++)
                result = result * i;
            return result;
        }
    }
}
